#include <libc.h>
//our includes
#include <utils.h>
#include <io.h>
#include <stats.h>
#include <error.h>


int __attribute__ ((__section__(".text.main")))
  main(void)
{
	/* Uncomment next line to call the initial routine for the test cases */
	//runjp_rank(11,35);	
	runjp();
    /*Next line, tries to move value 0 to CR3 register. This register is a privileged one, and so it will raise an exception */
    // __asm__ __volatile__ ("mov %0, %%cr3"::"r" (0) );

	/*
	int i=5;
	int pid;
	i = 50;
	while(i>0)
	{	
		pid = getpid();	
		switch (pid)
		{
			case 0: write(1,"Process with pid=0 is running\n",30); break;
			case 1: write(1,"Process with pid=1 is running\n",30); break;
			case 2: write(1,"Process with pid=2 is running\n",30); break;
			case 3: write(1,"Process with pid=3 is running\n",30); break;
			case 4: write(1,"Process with pid=4 is running\n",30); break;
			case 5: write(1,"Process with pid=5 is running\n",30); break;
			case 6: write(1,"Process with pid=6 is running\n",30); break;
			case 7: write(1,"Process with pid=7 is running\n",30); break;
			case 8: write(1,"Process with pid=8 is running\n",30); break;
			case 9: write(1,"Process with pid=9 is running\n",30); break;
			default: write(1,"getpid?\n",8);	
		}	
		i--;
	}
	
	fork();fork();fork();

	//Tesing getpid() and scheduling 

	i=100;
	while(i>0)
	{	
		pid = getpid();	
		switch (pid)
		{
			case 0: write(1,"Process with pid=0 is running\n",30); break;
			case 1: write(1,"Process with pid=1 is running\n",30); break;
			case 2: write(1,"Process with pid=2 is running\n",30); break;
			case 3: write(1,"Process with pid=3 is running\n",30); break;
			case 4: write(1,"Process with pid=4 is running\n",30); break;
			case 5: write(1,"Process with pid=5 is running\n",30); break;
			case 6: write(1,"Process with pid=6 is running\n",30); break;
			case 7: write(1,"Process with pid=7 is running\n",30); break;
			case 8: write(1,"Process with pid=8 is running\n",30); break;
			case 9: write(1,"Process with pid=9 is running\n",30); break;
			default: write(1,"getpid?\n",8);	
		}	
		i--;
	}

	//Testing exit 
	exit();
	while(1)
	{	
		pid = getpid();	
		switch (pid)
		{
			case 0: write(1,"Process with pid=0 is running\n",30); break;
			case 1: write(1,"Process with pid=1 is running\n",30); break;
			case 2: write(1,"Process with pid=2 is running\n",30); break;
			case 3: write(1,"Process with pid=3 is running\n",30); break;
			case 4: write(1,"Process with pid=4 is running\n",30); break;
			case 5: write(1,"Process with pid=5 is running\n",30); break;
			case 6: write(1,"Process with pid=6 is running\n",30); break;
			case 7: write(1,"Process with pid=7 is running\n",30); break;
			case 8: write(1,"Process with pid=8 is running\n",30); break;
			case 9: write(1,"Process with pid=9 is running\n",30); break;
			default: write(1,"getpid?\n",8);	
		}	
	}
	*/
	
}
